package demo15;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

public class ClientTest3 {
    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
        try {
            System.out.println("请输入账号：");
            String userName=input.next();
            System.out.println("请输入密码：");
            String password=input.next();
            Socket socket=new Socket("localhost",5000);
            User user=new User(userName,password);
            OutputStream os=socket.getOutputStream();
            ObjectOutputStream oos=new ObjectOutputStream(os);
            oos.writeObject(user);

            socket.shutdownOutput();
            InputStream is=socket.getInputStream();
            BufferedReader br=new BufferedReader(new InputStreamReader(is));
            String replay;
            if((replay=br.readLine())!=null){
                System.out.println("服务器说："+replay);
            }
            socket.close();
            os.close();
            oos.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
